﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="get_history_mail_sended.aspx.cs" Inherits="SQT.tracnghiem.Ajax.ASP.Letter.get_history_mail_sended" %>

<%@ Import Namespace="DataAccess" %>
<%@ Import Namespace="System.Linq" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <%try
        {
            var species = Request.QueryString["Species"];
            var mail_id = Request.QueryString["Email_ID"];

            var emailSendedColl = new TblContactController().FetchAll().Select(i => new { ID = i.Id, Sended = i.Sended }).ToList();
            if (species == "2")
                emailSendedColl = new TblFeedbackController().FetchAll().Select(i => new { ID = i.Id, Sended = i.Sended }).ToList();
            if (species == "3")
                emailSendedColl = new TblCustomerEmailController().FetchAll().Select(i => new { ID = i.Id, Sended = i.Sended }).ToList();

            var emailsended = emailSendedColl.Single(x => x.ID.Equals(Convert.ToInt32(mail_id))).Sended.ToString();

            string[] textthoi = Regex.Split(emailsended, @";;");

            int j = 0;
            for (int i = 0; i < textthoi.Length - 1; i++)
            {

                if (j == 3) j = 0;
                j++;

                if (j == 1)
                {
            %><img class="mp-staff-img w3-circle" src="../../../Content/avatar/<%= showAvatarSender(textthoi[i]) %>" /><h1><%= showSender(textthoi[i]) %></h1>
            <%}
                if (j == 2)
                {
            %>
            <p><%= textthoi[i] %></p>
            
            <%}
                if (j == 3)
                {
            %><p>Nội dung: <%= textthoi[i] %></p><hr />
            <%
                        }
                    }
                }
                catch
                {
                    %><p></p><%
                }
            %>
</body>
<%--<body>
    <% 
        var species = Request.Form["Species"];
        var mail_id = Request.Form["Email_ID"];

        var emailSendedColl = new TblContactController().FetchAll().Select(i => new { ID = i.Id, Sended = i.Sended }).ToList();
        if (species == "2")
            emailSendedColl = new TblFeedbackController().FetchAll().Select(i => new { ID = i.Id, Sended = i.Sended }).ToList();
        if (species == "3")
            emailSendedColl = new TblCustomerEmailController().FetchAll().Select(i => new { ID = i.Id, Sended = i.Sended }).ToList();

        var emailsended = emailSendedColl.Where(x=>x.ID==Convert.ToInt32(mail_id)).ToList();
        
            string[] textthoi = Regex.Split(emailsended.Select(x=>x.Sended).ToString(), @";;");
            for (int j = 0; j < textthoi.Length; j++)
            {
                if (j % 2 != 0)
                {
                    %><hr />
                    <h1>Người gửi: </h1>
                    <h1><%= textthoi[j] %></h1>
                    <br />
                    <%}
                        else
                        { %>
                    <h2>Nội dung: </h2>
                    <h2><%= textthoi[j]%></h2>
                    <%
                    }
                }
        %>
</body>--%>
</html>
